home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / MODULA_2 / 2394.ZIP / M2TOOLS1.ZIP / STRINGS2.DEF < prev    next >
Text File  |  1990-08-09  |  4KB  |  128 lines

  1. DEFINITION MODULE Strings2;
  2.  
  3.   CONST
  4.     MaxStringLength = 80;
  5.  
  6.   TYPE
  7.     STRING = ARRAY [0.. MaxStringLength] OF CHAR;
  8.  
  9. (*****************************************************************************)
  10. (*                                                                           *)
  11. (*                            P R O C E D U R E S                            *)
  12. (*                            -------------------                            *)
  13. (*                                                                           *)
  14. (*****************************************************************************)
  15.  
  16.   PROCEDURE Rept (Char   : CHAR;
  17.                   Num    : CARDINAL);
  18.  
  19.     (*  This procedure will display character Char, Num times.
  20.         The cursor is placed at the end of the string *)
  21.  
  22.  
  23.   PROCEDURE FastRept (Char   : CHAR;
  24.                       Num    : CARDINAL;
  25.                       Attrib : CARDINAL);
  26.  
  27.     (*  This procedure will display Num Chars of attribute type Attrib.
  28.         The cursor position remains at the beginning of the string *)
  29.  
  30.  
  31.   PROCEDURE InitStr (VAR String : ARRAY OF CHAR;
  32.                          Char   : CHAR;
  33.                          Length : CARDINAL);
  34.  
  35.     (*  This procedure will assign a string of characters to the string
  36.         String.
  37.         e.g. InitStr (Str, " ", 3) = Str := "   ";
  38.              InitStr (Str, 0C, 80) = Str := "" *)
  39.  
  40.  
  41.   PROCEDURE IsInString (Ch     : CHAR;
  42.                         String : ARRAY OF CHAR) : INTEGER;
  43.  
  44.     (* This procedure will determine whether Ch is in String.
  45.        Result -1 : not in string
  46.              >=0 : position in string *)
  47.  
  48.  
  49.   PROCEDURE MoveToRight (VAR Str    : ARRAY OF CHAR;
  50.                              Start  : CARDINAL;
  51.                              Places : CARDINAL);
  52.  
  53.     (*  This procedure will shift string Str Places places to the right,
  54.         starting at character position Start.
  55.  
  56.         The new inserted characters are spaces.
  57.  
  58.         e.g. MoveToRight ("ABCDEFG", 2, 2) -> Str = "AB  CDEFG" *)
  59.  
  60.  
  61.  
  62.   PROCEDURE MoveToLeft (VAR Str    : ARRAY OF CHAR;
  63.                             Start  : CARDINAL;
  64.                             Places : CARDINAL);
  65.  
  66.     (*  This procedure will shift string Str Places places to the left,
  67.         starting at character position Start.
  68.  
  69.         The eol character is moved as well.
  70.  
  71.         e.g. MoveToLeft ("ABCDEFG", 3, 2) -> Str = "ADEFG" *)
  72.  
  73.  
  74.   PROCEDURE LTrim (VAR String : ARRAY OF CHAR);
  75.  
  76.     (* This procedure will remove any spaces from the beginning of the string.
  77.        e.g.  "  1234" becomes "1234" *)
  78.  
  79.  
  80.   PROCEDURE Trim (VAR String : ARRAY OF CHAR);
  81.  
  82.     (* This procedure will remove any trailing spaces from the string.
  83.        e.g. "Hello World!  " becomes "Hello World!" *)
  84.  
  85.  
  86.   PROCEDURE EditString (VAR String       : ARRAY OF CHAR;
  87.                             TotStrLength : CARDINAL;
  88.                             KeyList      : ARRAY OF CHAR) : CARDINAL;
  89.  
  90.     (* This allows a default string String to be edited with upto TotStrLength
  91.        characters.  This function is not far dissimilar to the standard
  92.        Modula-2 procedure ReadString, except that the default string is
  93.        displayed and can be acted upon with the following keys:
  94.  
  95.        RightArrow - Move one character to the right (unless at max length)
  96.        LeftArrow  - Move one character to the left (unless at start of line)
  97.        Home       - Move to beginning of line
  98.        End        - Move to end of line
  99.  
  100.        The function also returns a number:
  101.        0          - The string was terminated normally (ie <RETURN>)
  102.        Scan Code  - Of one of the special characters entered in KeyList (eg
  103.                     PgUp, PgDn, F1, etc)
  104.        27         - If <ESC> pressed.
  105.  
  106.        See TestEdit.MOD for an example of this function's use. *)
  107.  
  108.  
  109.   PROCEDURE ws (String : ARRAY OF CHAR);
  110.  
  111.     (* Quick call of WriteString *)
  112.  
  113.  
  114.   PROCEDURE wls (String : ARRAY OF CHAR);
  115.  
  116.     (* Procedure call of WriteString with a WriteLn at the end *)
  117.  
  118.  
  119.   PROCEDURE WriteCentre (String : ARRAY OF CHAR);
  120.  
  121.     (*  This procedure will display string in the centre of a line *)
  122.  
  123.  
  124.   PROCEDURE WriteRight (String : ARRAY OF CHAR);
  125.  
  126.     (*  This procedure will display a string String justified to the right *)
  127.  
  128. END Strings2.